package com.jingdong.controller;


import com.jingdong.enity.User;
import com.jingdong.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    private UserService userService = new UserService();

    @RequestMapping("/register")
    public String register(User user) throws Exception {
        UserService userService = new UserService();
        boolean register = userService.register(user);
        return register ? "注册成功" : "注册失败";
    }


    @RequestMapping("/findAll")
    public List<User> findAll() throws Exception {
        return  userService.findAll();
    }


    //登录的功能
  @RequestMapping("/login")
  public String login(User user) throws Exception {
      return userService.login(user) ? "登录成功" : "登录失败";
  }



}
